package com.by.sbdemoby.config;

import com.by.sbdemoby.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @auth wzy
 * @date 2023/12/9 9:49
 */
@Configuration
public class FilterConfig {

//    @Bean
//    public FilterRegistrationBean filterExceptionHandler() {
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//
//        registration.setFilter(new ExceptionHandlerFilter());
//
//        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
//
//        return registration;
//    }

    @Bean
    public FilterRegistrationBean filterLogin() {
        FilterRegistrationBean registration = new FilterRegistrationBean();

        registration.setFilter(new MyFilter());

        String array[] = {"/index"};
        registration.setUrlPatterns(Arrays.asList(array));

        registration.setOrder(1);

        return registration;
    }
}
